package com.hjj.emp.dao.impl;

import com.hjj.emp.dao.EmpMangerDao;
import com.hjj.emp.entity.EmpManager;
import com.hjj.emp.utils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/**
 * @author Layton
 * @version 1.0
 * @date 2021/3/12 9:40
 */
public class EmpManagerDaoImpl implements EmpMangerDao {
    private QueryRunner queryRunner = new QueryRunner();
    public EmpManager select(String username){
        try {
            EmpManager empManager = queryRunner.query(DbUtils.getConnection(),
                    "select * from empmanager where username = ?",
                    new BeanHandler<EmpManager>(EmpManager.class),
                    username);
            return empManager;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
